﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LinQProject.Filters
{
    //public static class ProductDetailsFilters
    //{
    //    public static IQueryable<ProductDetail> ByCategory(this IQueryable<ProductDetail> qry, int categoryId)
    //    {
    //        return from e in qry where e.Product.ProductCategoryId == categoryId select e;
    //    }

    //    public static IQueryable<ProductDetail> ByMaterial(this IQueryable<ProductDetail> qry, int materialId)
    //    {
    //        return from he in qry where he.MaterialId == materialId select he;
    //    }

    //    public static IQueryable<ProductDetail> BetweenPrices(this IQueryable<ProductDetail> qry, decimal minPrice, decimal maxPrice )
    //    {
    //        return from p in qry where p.ProductDetailPrice >= minPrice && p.ProductDetailPrice <= maxPrice  select p;
    //    }

    //    public static IQueryable<ProductDetail> BySearchedName(this IQueryable<ProductDetail> qry, string name)
    //    {
    //        string[] searchedString = name.Split(' ');
    //        int noOfElements = searchedString.Count();
    //        IQueryable<ProductDetail> list = from p in qry select p;
    //        IQueryable<ProductDetail> listnew = list;
    //        string selectedElement;
    //        for (int i = 0; i < noOfElements ; i++)
    //        {
    //            selectedElement = searchedString[i];
    //            string selectedElement1 = selectedElement;
    //            listnew = list.Where(p => p.Product.ProductName.ToLower().Contains(selectedElement1.ToLower()) ||
    //                                      p.Product.ProductDescription.ToLower().Contains(selectedElement1.ToLower()) ||
    //                                      p.Product.ProductCategory.ProductCategoryName.ToLower().Contains(selectedElement1.ToLower()) ||
    //                                      p.Material.MaterialName.ToLower().Contains(selectedElement1.ToLower()));
    //            list = listnew;
    //        }

    //        return listnew;
    //    }
    //}
}
